package org.travel.app.configure;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author nmm
 * @date 2024-12-2024/12/29
 * @deriction 设置后台跨越访问
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                // 允许所有路径
                .allowedOrigins("http://127.0.0.1:5500")
                // 允许的源
                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
                // 允许的请求方法
                .allowCredentials(true);
                // 允许携带凭证
    }
}
